/*
 * sniffer.h
 *
 *  Created on: 2010-12-8
 *      Author: root
 */

#ifndef SNIFFER_H_
#define SNIFFER_H_
/*
*     Display an MAC address in readable format.
*/
#define HWADDR(addr) \
    ((unsigned char *)&addr)[0], \
    ((unsigned char *)&addr)[1], \
    ((unsigned char *)&addr)[2], \
    ((unsigned char *)&addr)[3], \
    ((unsigned char *)&addr)[4], \
    ((unsigned char *)&addr)[5]

/*
*     Display an IP address in readable format.
*/
#define NIPQUAD(addr) \
    ((unsigned char *)&addr)[0], \
    ((unsigned char *)&addr)[1], \
    ((unsigned char *)&addr)[2], \
    ((unsigned char *)&addr)[3]

#define HIPQUAD(addr) \
    ((unsigned char *)&addr)[3], \
    ((unsigned char *)&addr)[2], \
    ((unsigned char *)&addr)[1], \
    ((unsigned char *)&addr)[0]

#define PWORD(addr) \
    ((unsigned char *)&addr)[0], \
    ((unsigned char *)&addr)[1]

/********         函数区        ********/
void hex_print(const u_char *buf, int len, int offset);
int decode_eth(const u_char *buf);
int decode_ip(const u_char *buf);
int decode_arp(const u_char *buf);
int decode_tcp(const u_char *buf);
int decode_udp(const u_char *buf);

#endif /* SNIFFER_H_ */
